<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "users".
 *
 * @property int $id
 * @property string $name
 * @property string $pwd
 * @property string $email
 * @property int $tel
 */
class Users extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'users';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
                [['tel'], 'required'],
                [['tel'], 'length'=>11],

                [['name'], 'required'],
                [['name'], 'string', 'min'=>2,'max'=>4],

                [['wpd'], 'required'],
                [['pwd'], 'string', 'min'=>6,'max'=>10],

                [['email'], 'required'],
                [['email'], 'email'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => 'Name',
            'pwd' => 'Pwd',
            'email' => 'Email',
            'tel' => 'Tel',
        ];
    }

    public function add($data)
    {
        $this->email=$data['email'];
        $this->name=$data['name'];
        $this->pwd=$data['pwd'];
        $this->tel=$data['tel'];
        return $this->save();
    }

}
